{% extends 'layout.html' %}
{% load permission %}
{% block content %}
    <div style="margin-bottom: 5px">
        <a href="{% url 'level_add' %}" class="btn btn-success"><span class="glyphicon glyphicon-plus-sign"></span>
            新建</a>
    </div>
    <table class="table table-bordered">
        <thead>
        <tr>
            <th>ID</th>
            <th>标题</th>
            <th>折扣</th>
            {% if request|has_permission:"level_edit.level_delete" %}
                <th>操作</th>
            {% endif %}
        </tr>
        </thead>
        <tbody>
        {% for row in queryset %}
            <tr>
                <td>{{ row.id }}</td>
                <td>{{ row.title }}</td>
                <td>{{ row.discount }}%</td>
                {% if request|has_permission:"level_edit.level_delete" %}
                    <td>
                        {% edit_permission request 'level_edit' pk=row.id %}
                        {# 自定义属性cid为当前数据的的id为了方便接下来的操作 #}
                        {# <a cid="{{ row.id }}" class="btn btn-danger btn-xs btn-delete">删除</a> #}
                        {% delete_url_permission request 'level_delete' pk=row.id %}
                    </td>
                {% endif %}
            </tr>
        {% endfor %}

        </tbody>
    </table>

{% endblock %}
